package main

import (
	"encoding/json"
	"fmt"
)

func main() {

	monster := Monster{"zhangsan", 199, "浙江"}

	fmt.Println(monster)

	jsonStr, error := json.Marshal(monster)
	if error != nil {
		fmt.Println("错误信息", error)
	} else {
		fmt.Println(string(jsonStr))
	}

}

type Monster struct {
	Name string `json:"name"` //转小写
	Age  int    `json:"age"`
	Addr string `json:"addr"`
}
